/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_MagTrq.h
 *
 *  Created on: 2022
 *      Author: 64435
 */

#ifndef PERIPHERAL_LAYER_INC_LOS_MAGTRQ_H_
#define PERIPHERAL_LAYER_INC_LOS_MAGTRQ_H_

#include "LOS_SYS.h"

#define DIRX1_PIN PIN_HET_1
#define DIRY1_PIN PIN_HET_2
#define DIRZ1_PIN PIN_HET_3
#define DIRX2_PIN PIN_HET_6
#define DIRY2_PIN PIN_HET_8
#define DIRZ2_PIN PIN_HET_9

#define PWMX1_PIN PIN_HET_0
#define PWMY1_PIN PIN_HET_5
#define PWMZ1_PIN PIN_HET_4
#define PWMX2_PIN PIN_HET_13
#define PWMY2_PIN PIN_HET_20
#define PWMZ2_PIN PIN_HET_7

#define MagTrq_SW1 PIN_HET_9
#define MagTrq_SW2 PIN_HET_10

#define MagTrq_Forward 1
#define MagTrq_Reverse 0

extern uint8_t MTPOL_X1;
extern uint8_t MTPOL_Y1;
extern uint8_t MTPOL_Z1;
extern uint8_t MTPOL_X2;
extern uint8_t MTPOL_Y2;
extern uint8_t MTPOL_Z2;

void LOS_MagTrq_Set(uint32_t pin, uint32_t dir, uint32_t duty);
void LOS_MagTrq_TC(uint8_t nID, int8_t du);
void LOS_MagTrq_SetPol(uint8_t nID, uint8_t pol);
void LOS_MagTrq1_PWROn();
void LOS_MagTrq1_PWROff();
void LOS_MagTrq2_PWROn();
void LOS_MagTrq2_PWROff();

void LOS_MagTrq_SetDyn(int8_t* trq);

#endif /* PERIPHERAL_LAYER_INC_LOS_MAGTRQ_H_ */
